import request from '@/utils/request'

// 作业单位
export function listTaskcmpShort(query) {
  return request({
    url: '/baseinfo/taskcmp/shortlist',
    method: 'get',
    params: query
  })
}

// 查询飞行计划列表
export function listJobplan(query) {
  return request({
    url: '/uav/jobplan/list',
    method: 'get',
    params: query
  })
}

// 查询飞行计划详细
export function getJobplan(jobId) {
  return request({
    url: '/uav/jobplan/' + jobId,
    method: 'get'
  })
}

// 新增飞行计划
export function addJobplan(data) {
  return request({
    url: '/uav/jobplan',
    method: 'post',
    data: data
  })
}

// 修改飞行计划
export function updateJobplan(data) {
  return request({
    url: '/uav/jobplan',
    method: 'put',
    data: data
  })
}

// 删除飞行计划
export function delJobplan(jobId) {
  return request({
    url: '/uav/jobplan/' + jobId,
    method: 'delete'
  })
}

// 上报
export function submitJPToApprover(pam) {
  return request({
    url: '/uav/jobplan/submitb',
    method: 'post',
    data: pam
  })
}

// 航空器
export function listJobCraft(jobId) {
  return request({
    url: '/uav/jobplan/listCraft/' + jobId,
    method: 'get'
  })
}

// 空域
export function listJobArea(jobId) {
  return request({
    url: '/uav/jobplan/listArea/' + jobId,
    method: 'get'
  })
}

// 机场
export function listJobPort(jobId) {
  return request({
    url: '/uav/jobplan/listPort/' + jobId,
    method: 'get'
  })
}

// 航线
export function listJobLine(jobId) {
  return request({
    url: '/uav/jobplan/listLine/' + jobId,
    method: 'get'
  })
}

// 人员
export function listJobStaff(jobId) {
  return request({
    url: '/uav/jobplan/listStaff/' + jobId,
    method: 'get'
  })
}

export function listJobCraftSel(query) {
  return request({
    url: '/uav/jobplan/listCraftSel',
    method: 'get',
    params: query
  })
}

export function listJobAreaSel(query) {
  return request({
    url: '/uav/jobplan/listAreaSel',
    method: 'get',
    params: query
  })
}

export function listJobPortSel(query) {
  return request({
    url: '/uav/jobplan/listPortSel',
    method: 'get',
    params: query
  })
}

export function listJobLineSel(query) {
  return request({
    url: '/uav/jobplan/listLineSel',
    method: 'get',
    params: query
  })
}

export function listJobStaffSel(query) {
  return request({
    url: '/uav/jobplan/listStaffSel',
    method: 'get',
    params: query
  })
}





export function getJobplanWF(jobId) {
  return request({
    url: '/uav/jobplan/getWF/' + jobId,
    method: 'get'
  })
}

export function submitJPToReviewer(pam) {
  return request({
    url: '/uav/jobplan/submita',
    method: 'post',
    data: pam
  })
}

export function approveJP(pam) {
  return request({
    url: '/uav/jobplan/approve',
    method: 'post',
    data: pam
  })
}

export function rejectJP(pam) {
  return request({
    url: '/uav/jobplan/reject',
    method: 'post',
    data: pam
  })
}

export function recallJP(pam) {
  return request({
    url: '/uav/jobplan/recall',
    method: 'post',
    data: pam
  })
}

export function executeJP(pam) {
  return request({
    url: '/uav/jobplan/execute',
    method: 'post',
    data: pam
  })
}

export function doneJP(pam) {
  return request({
    url: '/uav/jobplan/done',
    method: 'post',
    data: pam
  })
}

export function cancelJP(pam) {
  return request({
    url: '/uav/jobplan/cancel',
    method: 'post',
    data: pam
  })
}

// 审批通过
export function passJP(pam) {
  return request({
    url: '/uav/jobplan/approve',
    method: 'post',
    data: pam
  })
}

export function delJobDetail(detailIds) {
  return request({
    url: '/uav/jobplan/deldetail/' + detailIds,
    method: 'delete'
  })
}

export function delJobDetailByJobId(jobId) {
  return request({
    url: '/uav/jobplan/deldetailall/' + jobId,
    method: 'delete'
  })
}

// 导出飞行计划
export function exportJobplan(query) {
  return request({
    url: '/uav/jobplan/export',
    method: 'get',
    params: query
  })
}

export function getJobMaxId() {
  return request({
   url: '/uav/jobplan/getjobmaxid',
   method: 'get'
 })
}

// export function generateWord(jobId, exportType) {
//   return request({
//     url: '/uav/jobplan/getword?jobId='+jobId+"&exportType="+Number(exportType)
//   })
// }
export function generateWord(jobId, exportType){
  return request({
    url:'/uav/jobplan/getwordNew',
    method:'get',
    params:{
      jobId:jobId,
      exportType:Number(exportType)
    },
    responseType:"blob"
  })
}

export function downloadWord(fileName) {
  const baseURL = process.env.VUE_APP_BASE_API;
	window.location.href = baseURL + "/common/downloadjp?fileName=" + encodeURI(fileName) + "&delete=" + true;
}

export function copyJobPlan(jobId) {
  return request({
    url: '/uav/jobplan/copyjobplan/' + jobId   
  })
}

// 获取任务编号
export function getTaskNo(){
  return request({
    url:'/uav/autotask/gettaskmaxid',
    method:'get'
  })
}

// 查询飞行任务列表
export function listJobtask(query) {
  return request({
    url: '/uav/autotask/list',
    method: 'get',
    params: query
  })
}

// 新增飞行任务
export function addJobtask(data) {
  return request({
    url: '/uav/autotask',
    method: 'post',
    data: data
  })
}

// 修改飞行任务
export function updateJobtask(data) {
  return request({
    url: '/uav/autotask',
    method: 'put',
    data: data
  })
}

// 删除飞行任务
export function delJobtask(taskId) {
  return request({
    url: '/uav/autotask/' + taskId,
    method: 'delete'
  })
}